

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>选择</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="/admin/layui-v2.4.5/layui/css/layui.css"  media="all">
    <link rel="stylesheet" href="/admin/css/admin.css"  media="all">
    <link rel="stylesheet" href="/admin/css/template.css"  media="all">
    <script src="https://cdn.staticfile.org/jquery/1.10.2/jquery.min.js"></script>
    <style>
        .selected_keywords{
            display: none;
            position: absolute;
            left: 0;
            top: 42px;
            padding: 5px 0;
            z-index: 899;
            min-width: 100%;
            border: 1px solid #d2d2d2;
            max-height: 300px;
            overflow-y: auto;
            background-color: #fff;
            border-radius: 2px;
            box-shadow: 0 2px 4px rgba(0,0,0,.12);
            box-sizing: border-box;
        }
        .list-group{
            padding: 0 10px;
            line-height: 36px;
            white-space: nowrap;
            overflow: hidden;
            text-overflow: ellipsis;
        }
        .list-group > li hover{
            background-color: #5FB878;
            color: #fff;
        }

    </style>
</head>
<body>
<script src="/admin/layui-v2.4.5/layui/layui.js" charset="utf-8"></script>
<div class="layui-fluid" style="padding: 1px "id="test1">
    <div class="layui-card">

        <div class="layui-card-body" style="padding: 1px;">
            <form class="layui-form" id="addPurchaseForm"lay-filter="form">

                <div class="layui-form-item">
                    <label class="layui-form-label">姓名：</label>
                    <div class="layui-input-block">
                        <select class="layui-input" name="name" id="supcoin" lay-verify="required">
                            <option>请选择姓名</option>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn" id="aaa" lay-submit lay-filter="component-form-element">立即提交</button>
                        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
</div>
<script>
    layui.use(['layer','form'], function() {
        var $ = layui.$ //由于layer弹层依赖jQuery，所以可以直接得到
            , layer = layui.layer
            , form = layui.form
            ,index = parent.layer.getFrameIndex(window.name)



        $(document).ready(function () {
            $.ajax({
                url: "/hospital/allUser",
                dataType: 'json',
                type: 'post',
                success: function (data) {
                    $.each(data, function (index, item) {
                        $('#supcoin').append("<option value = '" + item.userId + "'>" + item.ad_name + "</option>");// 下拉菜单里添加元素
                    });
                    form.render('select')

                }
            })
        })

        // /*子页面 回显data */
        // var callbackdata = function () {
        //
        //     var ad_name = "";
        //     //我这里循环拿取li列表的data中所有name和id
        //     for(var z = 0 ;z< length ;z++){
        //         if(0 != z){
        //             ad_name += ",";
        //         }
        //         ad_name = ad_name + $('.address-right').find('li').eq(z).data('ad_name');
        //     }
        //     //data里面可以存放很多需要回显的数据，在父页面调用这个function即可拿到data里面的数据达到回显的效果
        //     data ={
        //         data_name : ad_name,
        //     };
        //     //function返回一个data值，达到回显数据效果
        //     return data;
        // }

        //给父页面传值
        form.on('submit(component-form-element)', function(data){
            var obj = eval(data.field);
            console.log(obj)
            var name=obj.name;
            layer.close
            parent.layer.close(index);
            // parent.$('#Demo').find('.layui-table-cell laytable-cell-1-0-1').text('我被改变了');
            var tdArr = parent.$('tbody').find('tr').find("td").eq(1);
                //td里的内容
                var name1 = $(tdArr.eq(0)).text(name);
                $(tdArr.eq(1)).text("dfg");
                console.log("name"+name);
            return false;
        });



    })






</script>
</body>
</html>
